<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.security.MessageDigest" %>
<%@ page import="java.security.NoSuchAlgorithmException" %>
<%@ page import="java.math.BigInteger" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>保存数据</title>
</head>
<body>

<%
String restaurant_name = request.getParameter("restaurant_name");
String customer_name = request.getParameter("customer_name");
//
Class.forName("org.mariadb.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mariadb://localhost:3306/mealdb?user=root&password=1230321");
Statement stmt = conn.createStatement(); 
%>
<%
	//构造SQL写入数据到数据表
	String sql = "INSERT INTO dish (order_num, customer_name, meal, num) SELECT c.order_num, c.`name`, ct.meal_name, ct.num FROM cart ct INNER JOIN customers c ON c.`name` = ct.customer_name WHERE ct.customer_name = '"+customer_name+"';";
	System.out.print("sql= " + sql);
	out.print("响应行数： " + stmt.executeUpdate(sql));

	stmt.close();
	conn.close();

	//返回列页面
	out.print("修改完毕！");
	response.sendRedirect("myOrders.jsp?customer_name="+customer_name+"&restaurant_name="+restaurant_name);
	%>


</body>
</html>